package com.pxsw.apkfactory.datamanage;

import java.security.*;

public class PassSecurity {
	public static String PSecurity(String password) {
		byte[] passsecurity = null;
		try {
			MessageDigest alga = MessageDigest.getInstance("SHA-1");
			alga.update(password.getBytes());
			byte[] digesta=alga.digest();
			
			passsecurity = digesta;
		}catch(Exception e) {
			e.printStackTrace();
		}
		
		return byte2hex(passsecurity);
	}

	private static String byte2hex(byte[] b)
	{
	 String hs="";
	 String stmp="";
	 for (int n=0;n<b.length;n++)
	  {
	   stmp=(java.lang.Integer.toHexString(b[n] & 0XFF));
	   if (stmp.length()==1) hs=hs+"0"+stmp;
	   else hs=hs+stmp;
	  }
	 return hs.toUpperCase();
	}
}
